@echo off
cd %~dp0

echo -----------------------------------------------------
echo  MakeRelease.bat Start
echo -----------------------------------------------------

rem SDK  ======================================================================
set DEL_OPT1=1
set DEL_OPT2=2
.\Del_Text_From_Input_String.exe ../MILBCM0_API/MILBCM0_Header/build.bat DELETE_RELEASE 1 2
.\Del_Text_From_Input_String.exe ../MILBCM0_API/MILBCM0_Header/clean.bat DELETE_RELEASE 1 2
.\Del_Text_From_Input_String.exe ../MILBCM0_API/MILBCM0_Header/update.bat DELETE_RELEASE 1 2
.\Del_Text_From_Input_String.exe ../MILBCM0_API/Project/common.mk DELETE_RELEASE 1 2
.\Del_Text_From_Input_String.exe ../MILBCM0_API/Project/common.mk DELETE_OBJECT_RELEASE 2 2
.\Del_Text_From_Input_String.exe ../MILBCM0_API/Project/common.mk DELETE_SOURCE_RELEASE 2 2
.\Del_Text_From_Input_String.exe ../MILBCM0_API/build.bat DELETE_RELEASE 1 2
.\Del_Text_From_Input_String.exe ../MILBCM0_API/clean.bat DELETE_RELEASE 1 2
.\Del_Text_From_Input_String.exe ../MILBCM0_API/update.bat DELETE_RELEASE 1 2

rem BOARD SELECT start ========================================================
:BOARD_SELECT
echo Board select
echo  1: SNI Board
echo  2: SNI Small Board
set BOARD_SELECT_NO=
set /p BOARD_SELECT_NO="Select No. > "
if "%BOARD_SELECT_NO%"=="1" goto SELECTED_SNI
if "%BOARD_SELECT_NO%"=="2" goto SELECTED_SMALL
goto BOARD_SELECT

:SELECTED_SNI
.\Del_Text_From_Input_String.exe ../Custom/inc/user_custom.h DELETE_SMALL_BOARD 2 2
goto EXIT_SELECTED_BOARD

:SELECTED_SMALL
.\Del_Text_From_Input_String.exe ../Custom/inc/user_custom.h DELETE_SMALL_BOARD 1 2
goto EXIT_SELECTED_BOARD

:EXIT_SELECTED_BOARD
rem BOARD SELECT end ==========================================================

rem ES1/ES3 SELECT start ======================================================
:ES_SELECT
echo ES1/ES3 select
echo  1: ES1
echo  2: ES3
set ES_SELECT_NO=
set /p ES_SELECT_NO="Select No. > "
if "%ES_SELECT_NO%"=="1" goto SELECTED_ES1
if "%ES_SELECT_NO%"=="2" goto SELECTED_ES3
goto ES_SELECT

:SELECTED_ES1
del /f /q ..\Base\doc\MILBCM0_Base_History_ES3.txt
del /f /q ..\Base\doc\MILBCM0_Base_MainPage_ES3.txt
.\Del_Text_From_Input_String.exe ../Custom/inc/user_custom.h DELETE_ES3 2 2
.\Del_Text_From_Input_String.exe ../Base/init/src/startup_hw.s DELETE_ES3 2 2
.\Del_Text_From_Input_String.exe ../Base/init/src/startup_hw.s DELETE_ES1 1 2
.\Del_Text_From_Input_String.exe ../Base/loader/src/loader.c DELETE_ES3 2 2
.\Del_Text_From_Input_String.exe ../Base/loader/src/loader.c DELETE_ES1 1 2
goto EXIT_SELECTED_ES

:SELECTED_ES3
.\Del_Text_From_Input_String.exe ../Custom/inc/user_custom.h DELETE_ES3 1 2
.\Del_Text_From_Input_String.exe ../Base/init/src/startup_hw.s DELETE_ES3 1 2
.\Del_Text_From_Input_String.exe ../Base/init/src/startup_hw.s DELETE_ES1 2 2
.\Del_Text_From_Input_String.exe ../Base/loader/src/loader.c DELETE_ES3 1 2
.\Del_Text_From_Input_String.exe ../Base/loader/src/loader.c DELETE_ES1 2 2
if exist ..\Base\doc\MILBCM0_Base_History_ES3.txt move /y ..\Base\doc\MILBCM0_Base_History_ES3.txt ..\Base\doc\MILBCM0_Base_History.txt
if exist ..\Base\doc\MILBCM0_Base_MainPage_ES3.txt move /y ..\Base\doc\MILBCM0_Base_MainPage_ES3.txt ..\Base\doc\MILBCM0_Base_MainPage.txt
goto EXIT_SELECTED_ES

:EXIT_SELECTED_ES
set GLOBAL_ES_SELECT_NO=%ES_SELECT_NO%
rem ES1/ES3 SELECT end ======================================================

rem SENSOR SELECT start ======================================================
:SENSOR_SELECT
echo Sensor select
echo  1: Single Sensor
echo  2: Dual Sensor
set SENSOR_SELECT_NO=
set /p SENSOR_SELECT_NO="Select No. > "
if "%SENSOR_SELECT_NO%"=="1" goto SELECTED_SINGLE
if "%SENSOR_SELECT_NO%"=="2" goto SELECTED_DUAL
goto SENSOR_SELECT

:SELECTED_SINGLE
.\Del_Text_From_Input_String.exe ../Base/init/src/startup_hw.s DELETE_SENSOR_DUAL 2 2
goto EXIT_SELECTED_SENSOR

:SELECTED_DUAL
.\Del_Text_From_Input_String.exe ../Base/init/src/startup_hw.s DELETE_SENSOR_DUAL 1 2
goto EXIT_SELECTED_SENSOR

:EXIT_SELECTED_SENSOR
rem SENSOR SELECT end ======================================================

echo *** Clean object files ...
cd ..
call clean.bat

echo *** Start MILBCM0_Header for release batch ...
cd .\MILBCM0_API\MILBCM0_Header\Project
call .\MakeRelease.bat
cd ..

echo *** Build MILBCM0_Header library ...
call .\build.bat
del /f /q .\lib\MILBCM0.txt
del /f /q .\log.txt

echo *** Start MILBCM0_API for release batch ...
cd ..\Project
call .\MakeRelease.bat
cd ..

echo *** Build MILBCM0_API library ...
call .\build.bat
del /f /q .\lib\MILBCM0_API.txt
del /f /q .\log.txt
del /f /q .\PGR_update.bat
del /f /q .\PGRelief_out.csv
del /f /q .\Project\makeRelease.bat
del /f /q .\Project\PGReliefCheck.exe
del /f /q .\Project\setenv.bat

echo *** Create MILBCM0_API Doxygen ...
cd doc
call .\MILBCM0_API.doxy.bat
rmdir /s /q .\figures
del /f /q .\log.txt
del /f /q .\MILBCM0_API.doxy
del /f /q .\MILBCM0_API.doxy.bat
del /f /q .\MILBCM0_API_Category.txt
del /f /q .\MILBCM0_API_History.txt
del /f /q .\MILBCM0_API_MainPage.txt
del /f /q .\MILBCM0_API_PageFooter.txt
del /f /q .\MILBCM0_API_PageHeader.txt

echo *** Build RS_MILBCM0 ...
cd ..\..
call .\build.bat
del /f /q .\log.txt

echo *** Create MILBCM0_Base Doxygen ...
cd .\Base\doc
call .\MILBCM0_Base.doxy.bat
rmdir /s /q .\figures
del /f /q .\log.txt
del /f /q .\MILBCM0_Base.doxy
del /f /q .\MILBCM0_Base.doxy.bat
del /f /q .\MILBCM0_Base_Category.txt
del /f /q .\MILBCM0_Base_History.txt
del /f /q .\MILBCM0_Base_MainPage.txt
del /f /q .\MILBCM0_Base_PageFooter.txt
del /f /q .\MILBCM0_Base_PageHeader.txt


echo *** Delete disused files ...
rem [svn]
cd ..\..
for /r %%i in (.svn) do if exist %%i rd /s /q %%i
rem [dep]
for /r %%i in (dep) do if exist %%i rd /s /q %%i
rem [obj]
for /r %%i in (obj) do if exist %%i rd /s /q %%i

rem [Project]

rem [PGRelief]
del /f /q .\Project\PGReliefCheck.exe
del /f /q .\PGR_update.bat
del /f /q .\PGRelief_out.csv

rem [mvPlus]

echo *** Delete disused lines ...
.\Project\Del_Text_From_Input_String.exe ./ DELETE_RELEASE 1 2
.\Project\Del_Text_From_Input_String.exe ./build.bat DELETE_RELEASE 1 2
.\Project\Del_Text_From_Input_String.exe ./clean.bat DELETE_RELEASE 1 2
.\Project\Del_Text_From_Input_String.exe ./update.bat DELETE_RELEASE 1 2

echo *** Delete disused files ...
del /f /q .\Project\Del_Text_From_Input_String.exe

echo.
echo -----------------------------------------------------
echo  MakeRelease.bat End
echo -----------------------------------------------------
echo.

echo %0
echo complete !
echo.

del /f "%~dp0%~nx0"
